/*****  Component, by Ben Bi <prince.bi@gmail.com>  created at: 12/23/2009 4:10:45 PM  *****/

/***** variables declartion section, begin *****/
var appLayout;
/***** variables declartion section, end *****/


/***** init section, begin *****/
$(document).ready(function(){
//   $('body').layout({ applyDefaultStyles: true });

   appLayout = $('body').layout({
   // enable showOverflow on west-pane so popups will overlap north pane
//   west__showOverflowOnHover: true
      east__initClosed: true
    //,	west__fxSettings_open: { easing: "easeOutBounce", duration: 750 }
   });

   initApp();

   initCombobox();

   bindEvents();
});

/*
 * init application
 */
function initApp()
{
//    appLayout.close('east');
}

/*
 *
 */
function bindEvents()
{
    $("#btnSubmit").bind("click", function(e){

        $.ajax({
            url: BASE_URL + "test/ajaxTest" ,
            global: true,
            type: "GET",
            data: $("#testForm").serialize(),
            dataType: "json",
            success: function(jsonData){
                wacDebugLog($.dump(jsonData));
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                wacDebugLog("getFormData Error: " + $(this).dump()); // the options for this ajax request
            }
        });
//       wacDebugLog($("btnSubmit"));
    });
}

/*
 *
 */
function initCombobox()
{
    // Creating a template for each matching result
        $('#comboboxTest').flexbox(BASE_URL + 'goodsCategory/GetIdNameHashInFormat?data_format=jsonFlexbox', {
//            resultTemplate: '<div class="col1">{id}</div><div class="col2">{name}</div>',
            initialValue: "101",
            watermark: 'Enter account number or name',
            noResultsText : '没找到相符项!',
            width: 250,
            maxVisibleRows: 15,
            autoCompleteFirstMatch: true,
            queryDelay: 200,
            minChars: 1,
            onSelect: function() {
                wacDebugLog('You selected "' + this.value + '", ' +
                                       'which has a hidden value of ' + this.getAttribute('hiddenValue'));
            }
        });
        $('#comboboxTest_input').val("c3131111");
//        $('#comboboxTest').setValue($('#comboboxTest').val());
//        $('#comboboxTest').attr("value", "84");

}


/***** init section, end *****/

